The near infrared (IR) absorption spectra of starburst galaxies show several atomic and molecular lines from red supergiants which can be used to infer reliable stellar abundances. The metals locked in stars give a picture of the galaxy metallicity prior to the last burst of star formation. The enrichment of the new generation of stars born in the last burst can be traced by measuring the hot gas in the X-rays. For the first time detailed stellar abundances in the nuclear region of the starburst galaxy M82 have been obtained. They are compared with those of the hot gas as derived from an accurate re-analysis of the XMM and Chandra nuclear X-ray spectra. The cool stars and the hot gas suggest [Fe/H]=-0.35+/-0.2 dex, and an overall [Si,Mg/Fe] enhancement by 0.4 and 0.5 dex, respectively. This is consistent with a major chemical enrichment by SNe II explosions in recursive bursts on short timescales. Oxygen is more puzzling to interpret since it is enhanced by 0.3 dex in stars and depleted by 0.2 dex in the hot gas. None of the standard enrichment scenarios can fully explain such a behavior when compared with the other alpha-elements.